﻿Public Class FormSettings
    Private autoStartManager As New AutoStartManager()

    Private Sub FormSettings_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ' 使窗体圆角
        SetControlRound(Me, 10)


        ' 初始化控件
        chkAutoStart.Checked = autoStartManager.IsAutoStartEnabled()

        ' 初始化控件，读取设置文件中的值
        chkWindowA.Checked = SettingsHelper.ShouldShowWindowA()
        chkWindowB.Checked = SettingsHelper.ShouldShowWindowB()
        chkWindowC.Checked = SettingsHelper.ShouldShowWindowC()
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If chkAutoStart.Checked Then
            autoStartManager.EnableAutoStart()
            Logger.Log("用户启用了开机自启动功能")
        Else
            autoStartManager.DisableAutoStart()
            Logger.Log("用户取消了开机自启动功能")
        End If

        ' 保存用户设置的窗口显示状态
        SettingsHelper.SetWindowAState(chkWindowA.Checked)
        SettingsHelper.SetWindowBState(chkWindowB.Checked)
        SettingsHelper.SetWindowCState(chkWindowC.Checked)

        MessageBox.Show("设置已保存", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Me.Close()
    End Sub

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Dispose()
    End Sub
End Class